<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">
  <link rel="stylesheet" href="//cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.css">
  <link rel="stylesheet" href="/lib/pace/pace-theme-minimal.min.css">
  <script src="/lib/pace/pace.min.js"></script>

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"yoursite.com","root":"/","scheme":"Pisces","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":true},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":true,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":-1,"unescape":false,"preload":true},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"./public/search.xml"};
  </script>

  <meta name="description" content="本文主要内容字体标签： &lt;font&gt;、 &lt;b&gt;、 &lt;u&gt; 、&lt;sup&gt; 、&lt;sub&gt; 超链接 &lt;a&gt; 字体标签特殊字符（转义字符） &amp;nbsp;：空格    （non-breaking spacing，不断打空格） &amp;lt;：小于号（less than） &amp;gt;：大于号（greater than） &amp;">
<meta property="og:type" content="article">
<meta property="og:title" content="05-HTML标签：字体标签和超链接">
<meta property="og:url" content="http://yoursite.com/2020/07/07/05-HTML%E6%A0%87%E7%AD%BE%EF%BC%9A%E5%AD%97%E4%BD%93%E6%A0%87%E7%AD%BE%E5%92%8C%E8%B6%85%E9%93%BE%E6%8E%A5/index.html">
<meta property="og:site_name" content="GipBaby270&#39;s Blog">
<meta property="og:description" content="本文主要内容字体标签： &lt;font&gt;、 &lt;b&gt;、 &lt;u&gt; 、&lt;sup&gt; 、&lt;sub&gt; 超链接 &lt;a&gt; 字体标签特殊字符（转义字符） &amp;nbsp;：空格    （non-breaking spacing，不断打空格） &amp;lt;：小于号（less than） &amp;gt;：大于号（greater than） &amp;">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://img.smyhvae.com/2015-10-01-cnblogs_html_11.png">
<meta property="og:image" content="http://img.smyhvae.com/2015-10-01-cnblogs_html_12.png">
<meta property="og:image" content="http://img.smyhvae.com/2015-10-01-cnblogs_html_13.png">
<meta property="og:image" content="http://img.smyhvae.com/2015-10-01-cnblogs_html_15.png">
<meta property="og:image" content="http://img.smyhvae.com/20180118_2340.png">
<meta property="og:image" content="http://img.smyhvae.com/2015-10-01-cnblogs_html_14.png">
<meta property="og:image" content="http://img.smyhvae.com/2015-10-01-cnblogs_html_10.png">
<meta property="og:image" content="http://img.smyhvae.com/2015-10-01-cnblogs_html_16.png">
<meta property="og:image" content="http://img.smyhvae.com/2015-10-01-cnblogs_html_17.png">
<meta property="og:image" content="http://img.smyhvae.com/2015-10-01-cnblogs_html_18.png">
<meta property="og:image" content="http://img.smyhvae.com/20170630_1415.png">
<meta property="article:published_time" content="2020-07-07T10:24:42.739Z">
<meta property="article:modified_time" content="2020-07-07T11:16:19.049Z">
<meta property="article:author" content="Gip886">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://img.smyhvae.com/2015-10-01-cnblogs_html_11.png">

<link rel="canonical" href="http://yoursite.com/2020/07/07/05-HTML%E6%A0%87%E7%AD%BE%EF%BC%9A%E5%AD%97%E4%BD%93%E6%A0%87%E7%AD%BE%E5%92%8C%E8%B6%85%E9%93%BE%E6%8E%A5/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>05-HTML标签：字体标签和超链接 | GipBaby270's Blog</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    
    <a href="https://github.com/Gip886" target="_blank" rel="noopener" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#64CEAA; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
    
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">GipBaby270's Blog</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">Fighting for BAT!</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2020/07/07/05-HTML%E6%A0%87%E7%AD%BE%EF%BC%9A%E5%AD%97%E4%BD%93%E6%A0%87%E7%AD%BE%E5%92%8C%E8%B6%85%E9%93%BE%E6%8E%A5/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/%E5%A4%B4%E5%83%8F.jpg">
      <meta itemprop="name" content="Gip886">
      <meta itemprop="description" content="为了更美好的明天而战">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="GipBaby270's Blog">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          05-HTML标签：字体标签和超链接
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              

              <time title="创建时间：2020-07-07 18:24:42 / 修改时间：19:16:19" itemprop="dateCreated datePublished" datetime="2020-07-07T18:24:42+08:00">2020-07-07</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/HTML%E5%9F%BA%E7%A1%80/" itemprop="url" rel="index"><span itemprop="name">HTML基础</span></a>
                </span>
            </span>

          
            <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv" style="display: none;">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span id="busuanzi_value_page_pv"></span>
            </span><br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>2.9k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>3 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h2 id="本文主要内容"><a href="#本文主要内容" class="headerlink" title="本文主要内容"></a>本文主要内容</h2><p>字体标签： <code>&lt;font&gt;</code>、 <code>&lt;b&gt;</code>、 <code>&lt;u&gt;</code> 、<code>&lt;sup&gt;</code> 、<code>&lt;sub&gt;</code></p>
<p>超链接 <code>&lt;a&gt;</code></p>
<h2 id="字体标签"><a href="#字体标签" class="headerlink" title="字体标签"></a>字体标签</h2><h3 id="特殊字符（转义字符）"><a href="#特殊字符（转义字符）" class="headerlink" title="特殊字符（转义字符）"></a>特殊字符（转义字符）</h3><ul>
<li><code>&amp;nbsp;</code>：空格    （non-breaking spacing，不断打空格）</li>
<li><code>&amp;lt;</code>：小于号（less than）</li>
<li><code>&amp;gt;</code>：大于号（greater than）</li>
<li><code>&amp;amp;</code>：符号<code>&amp;</code></li>
<li><code>&amp;quot;</code>：双引号</li>
<li><code>&amp;apos;</code>：单引号</li>
<li><code>&amp;copy;</code>：版权<code>©</code></li>
<li><code>&amp;trade;</code>：商标<code>™</code></li>
<li><code>&amp;#32464;</code>：文字<code>绐</code>。其实，<code>#32464</code>是汉字<code>绐</code>的unicode编码。<a id="more"></a></li>
</ul>
<p>比如说，你想把<code>&lt;p&gt;</code>作为一个文本在页面上显示，直接写<code>&lt;p&gt;</code>是肯定不行的，因为这代表的是一个段落标签，所以这里需要用到<strong>转义字符</strong>。应该这么写：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">这是一个HTML语言的<span class="symbol">&amp;lt;</span>p<span class="symbol">&amp;gt;</span>标签</span><br></pre></td></tr></table></figure>
<p>正确的效果如下：</p>
<p><img src="http://img.smyhvae.com/2015-10-01-cnblogs_html_11.png" alt="Paste_Image.png"></p>
<p>错误的效果如下：</p>
<p><img src="http://img.smyhvae.com/2015-10-01-cnblogs_html_12.png" alt="Paste_Image.png"></p>
<p>其实我们只要记住前三个符号就行了，其他的在需要的时候查一下就行了。而且，EditPlus软件中是可以直接点击这些符号进行选择的：</p>
<p><img src="http://img.smyhvae.com/2015-10-01-cnblogs_html_13.png" alt="Paste_Image.png"></p>
<p>来一张表格，方便需要的时候查询：</p>
<table>
<thead>
<tr>
<th align="left">特殊字符</th>
<th align="left">描述</th>
<th align="left">字符的代码</th>
</tr>
</thead>
<tbody><tr>
<td align="left"></td>
<td align="left">空格符</td>
<td align="left"><code>&amp;nbsp;</code></td>
</tr>
<tr>
<td align="left">&lt;</td>
<td align="left">小于号</td>
<td align="left"><code>&amp;lt;</code></td>
</tr>
<tr>
<td align="left">&gt;</td>
<td align="left">大于号</td>
<td align="left"><code>&amp;gt;</code></td>
</tr>
<tr>
<td align="left">&amp;</td>
<td align="left">和号</td>
<td align="left"><code>&amp;amp;</code></td>
</tr>
<tr>
<td align="left">￥</td>
<td align="left">人民币</td>
<td align="left"><code>&amp;yen;</code></td>
</tr>
<tr>
<td align="left">©</td>
<td align="left">版权</td>
<td align="left"><code>&amp;copy;</code></td>
</tr>
<tr>
<td align="left">®</td>
<td align="left">注册商标</td>
<td align="left"><code>&amp;reg;</code></td>
</tr>
<tr>
<td align="left">°</td>
<td align="left">摄氏度</td>
<td align="left"><code>&amp;deg;</code></td>
</tr>
<tr>
<td align="left">±</td>
<td align="left">正负号</td>
<td align="left"><code>&amp;plusmn;</code></td>
</tr>
<tr>
<td align="left">×</td>
<td align="left">乘号</td>
<td align="left"><code>&amp;times;</code></td>
</tr>
<tr>
<td align="left">÷</td>
<td align="left">除号</td>
<td align="left"><code>&amp;divide;</code></td>
</tr>
<tr>
<td align="left">²</td>
<td align="left">平方2（上标2）</td>
<td align="left"><code>&amp;sup2;</code></td>
</tr>
<tr>
<td align="left">³</td>
<td align="left">立方3（上标3）</td>
<td align="left"><code>&amp;sup3;</code></td>
</tr>
</tbody></table>
<h3 id="下划线、中划线、斜体"><a href="#下划线、中划线、斜体" class="headerlink" title="下划线、中划线、斜体"></a>下划线、中划线、斜体</h3><ul>
<li><p><code>&lt;u&gt;</code>：下划线标记</p>
</li>
<li><p><code>&lt;s&gt;</code>或<code>&lt;del&gt;</code>：中划线标记（删除线）</p>
</li>
<li><p><code>&lt;i&gt;</code>或<code>&lt;em&gt;</code>：斜体标记</p>
</li>
</ul>
<p>效果：</p>
<p><img src="http://img.smyhvae.com/2015-10-01-cnblogs_html_15.png" alt="Paste_Image.png"></p>
<p>上面的这几个标签，常用于做一些小装饰、小图标。比如：</p>
<p><img src="http://img.smyhvae.com/20180118_2340.png" alt></p>
<p>这张图中，我们通过查看京东网站的代码发现，箭头处的小图标都是用的标签<code>&lt;i&gt;</code>。</p>
<h3 id="粗体标签-lt-b-gt-或-lt-strong-gt-（已废弃）"><a href="#粗体标签-lt-b-gt-或-lt-strong-gt-（已废弃）" class="headerlink" title="粗体标签&lt;b&gt;或&lt;strong&gt;（已废弃）"></a>粗体标签<code>&lt;b&gt;</code>或<code>&lt;strong&gt;</code>（已废弃）</h3><p>效果：</p>
<p><img src="http://img.smyhvae.com/2015-10-01-cnblogs_html_14.png" alt="Paste_Image.png"></p>
<h3 id="字体标签-lt-font-gt-（已废弃）"><a href="#字体标签-lt-font-gt-（已废弃）" class="headerlink" title="字体标签&lt;font&gt;（已废弃）"></a>字体标签<code>&lt;font&gt;</code>（已废弃）</h3><p>属性：</p>
<ul>
<li><p><code>color=&quot;红色&quot;</code>或<code>color=&quot;#ff00cc&quot;</code>或<code>color=&quot;new rgb(0,0,255)&quot;</code>：设置字体颜色。<br>  设置方式：单词 \  #ff00cc \   rgb(0,0,255)</p>
</li>
<li><p><code>size</code>：设置字体大小。 取值范围只能是：1至7。取值时，如果取值大于7那就按照7来算，如果取值小于1那就按照1来算。如果想要更大的字体，那就只能通过css样式来解决。</p>
</li>
<li><p><code>face=&quot;微软雅黑&quot;</code>：设置字体类型。</p>
</li>
</ul>
<p>举例：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">font</span> <span class="attr">face</span>=<span class="string">"微软雅黑"</span> <span class="attr">color</span>=<span class="string">"#FF0000"</span> <span class="attr">size</span>=<span class="string">"10"</span>&gt;</span>vae<span class="tag">&lt;/<span class="name">font</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>效果：</p>
<p><img src="http://img.smyhvae.com/2015-10-01-cnblogs_html_10.png" alt="Paste_Image.png"></p>
<h3 id="上标-lt-sup-gt-下标-lt-sub-gt"><a href="#上标-lt-sup-gt-下标-lt-sub-gt" class="headerlink" title="上标&lt;sup&gt;   下标&lt;sub&gt;"></a>上标<code>&lt;sup&gt;</code>   下标<code>&lt;sub&gt;</code></h3><p>上小标这两个标签容易混淆，怎么记呢？这样记：<code>b</code>的意思是<code>bottom：底部</code><br>举例：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">O<span class="tag">&lt;<span class="name">sup</span>&gt;</span>2<span class="tag">&lt;/<span class="name">sup</span>&gt;</span>    5<span class="tag">&lt;<span class="name">sub</span>&gt;</span>3<span class="tag">&lt;/<span class="name">sub</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p>效果：</p>
<p><img src="http://img.smyhvae.com/2015-10-01-cnblogs_html_16.png" alt="Paste_Image.png"></p>
<h2 id="三、超链接"><a href="#三、超链接" class="headerlink" title="三、超链接"></a>三、超链接</h2><p>超链接有三种形式，下面分别讲讲。</p>
<h3 id="1、外部链接：链接到外部文件"><a href="#1、外部链接：链接到外部文件" class="headerlink" title="1、外部链接：链接到外部文件"></a>1、外部链接：链接到外部文件</h3><p>举例：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">"02页面.html"</span>&gt;</span>点击进入另外一个文件<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>a是英语<code>anchor</code>“锚”的意思，就好像这个页面往另一个页面扔出了一个锚。是一个文本级的标签。</p>
<p>href（hypertext reference）：超文本地址。读作“喝瑞夫”，不要读作“喝夫”。</p>
<p>效果：</p>
<p><img src="http://img.smyhvae.com/2015-10-01-cnblogs_html_17.png" alt="Paste_Image.png"></p>
<p>当然，我们也可以直接点进链接，访问一个网址。代码举例如下：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">"http://www.baidu.com"</span> <span class="attr">target</span>=<span class="string">"_blank"</span>&gt;</span>点我点我<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br></pre></td></tr></table></figure>

<h3 id="2、锚链接"><a href="#2、锚链接" class="headerlink" title="2、锚链接"></a>2、锚链接</h3><p><strong>锚链接</strong>：给超链接起一个名字，作用是<strong>在本页面或者其他页面的的不同位置进行跳转</strong>。比如说，在网页底部有一个向上箭头，点击箭头后回到顶部，这个就可以利用锚链接。</p>
<p>首先我们要创建一个<strong>锚点</strong>，也就是说，使用<code>name</code>属性或者<code>id</code>属性给那个特定的位置起个名字。效果如下：</p>
<p><img src="http://img.smyhvae.com/2015-10-01-cnblogs_html_18.png" alt="Paste_Image.png"></p>
<p>上图中解释：</p>
<p>第11行代码表示，顶部这个锚的名字叫做name1。<br>然后在底部设置超链接，点击时将回到顶部（此时，网页中的url的末尾也出现了<code>#name1</code>）。注意<strong>上图中红框部分的<code>#</code>号不要忘记了</strong>，表示跳到名为name1的特定位置，这是规定。如果少了<code>#</code>号，点击之后，就会跳到name1这个文件或者name1这个文件夹中去。</p>
<p>如果我们将上图中的第28行代码写成：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">"a.html#name1"</span>&gt;</span>回到顶部<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>那就表示，点击之后，跳转到<code>a.html</code>页面的<code>name1锚点</code>中去。</p>
<p>说明：name属性是HTML4.0以前使用的，id属性是HTML4.0后才开始使用。为了向前兼容，因此，name和id这两个属性都要写上，并且值是一样的。</p>
<h3 id="3、邮件链接"><a href="#3、邮件链接" class="headerlink" title="3、邮件链接"></a>3、邮件链接</h3><p>代码举例：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">"mailto:xxx@163.com"</span>&gt;</span>点击进入我的邮箱<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>效果：点击之后，会弹出outlook，作用不大。</p>
<h3 id="超链接的属性"><a href="#超链接的属性" class="headerlink" title="超链接的属性"></a>超链接的属性</h3><ul>
<li><code>href</code>：目标URL</li>
<li><code>title</code>：悬停文本。</li>
<li><code>name</code>：主要用于设置一个锚点的名称。</li>
<li><code>target</code>：告诉浏览器用什么方式来打开目标页面。<code>target</code>属性有以下几个值：<ul>
<li><code>_self</code>：在同一个网页中显示（默认值）</li>
<li><code>_blank</code>：<strong>在新的窗口中打开</strong>。</li>
<li><code>_parent</code>：在父窗口中显示</li>
<li><code>_top</code>：在顶级窗口中显示</li>
</ul>
</li>
</ul>
<p><code>title</code>属性举例：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">"09_img.html"</span> <span class="attr">title</span>=<span class="string">"很好看哦"</span>&gt;</span>结婚照<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>效果如下：</p>
<p><img src="http://img.smyhvae.com/20170630_1415.png" alt></p>
<p><code>target</code>属性举例：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">"1.html"</span> <span class="attr">title</span>=<span class="string">"悬停文本"</span> <span class="attr">target</span>=<span class="string">"_blank"</span>&gt;</span>链接的内容<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>blank就是“空白”的意思，就表示新建一个空白窗口。为啥有一个_ ，就是规定，无需解释。<br>也就是说，如果不写<code>target=”_blank”</code>那么就是在相同的标签页打开，如果写了<code>target=”_blank”</code>，就是在新的空白标签页中打开。</p>
<h4 id="备注1：分清楚img和a标签的各自的属性"><a href="#备注1：分清楚img和a标签的各自的属性" class="headerlink" title="备注1：分清楚img和a标签的各自的属性"></a>备注1：分清楚img和a标签的各自的属性</h4><p>区别如下：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">"1.jpg"</span> /&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">"1.html"</span>&gt;</span><span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br></pre></td></tr></table></figure>
<h4 id="备注2：a是一个文本级的标签"><a href="#备注2：a是一个文本级的标签" class="headerlink" title="备注2：a是一个文本级的标签"></a>备注2：a是一个文本级的标签</h4><p>比如一个段落中的所有文字都能够被点击，那么应该是p包裹a：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">p</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">""</span>&gt;</span>段落段落段落段落段落段落<span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">p</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>而不是a包裹p：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">""</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">p</span>&gt;</span></span><br><span class="line">		段落段落段落段落段落段落</span><br><span class="line">	<span class="tag">&lt;/<span class="name">p</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">a</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>a的语义要小于p，a就是可以当做文本来处理，所以p里面相当于放的就是纯文字。</p>

    </div>

    
    
    
        <div class="reward-container">
  <div>坚持原创技术分享，您的支持将鼓励我继续分享！</div>
  <button onclick="var qr = document.getElementById('qr'); qr.style.display = (qr.style.display === 'none') ? 'block' : 'none';">
    打赏
  </button>
  <div id="qr" style="display: none;">
      
      <div style="display: inline-block;">
        <img src="/images/wechatpay.png" alt="Gip886 微信支付">
        <p>微信支付</p>
      </div>

  </div>
</div>


      <footer class="post-footer">

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2020/07/07/04-HTML%E6%A0%87%E7%AD%BE%EF%BC%9A%E6%8E%92%E7%89%88%E6%A0%87%E7%AD%BE/" rel="prev" title="04-HTML标签：排版标签">
      <i class="fa fa-chevron-left"></i> 04-HTML标签：排版标签
    </a></div>
      <div class="post-nav-item">
    <a href="/2020/07/07/06-HTML%E6%A0%87%E7%AD%BE%EF%BC%9A%E5%9B%BE%E7%89%87%E6%A0%87%E7%AD%BE/" rel="next" title="06-HTML标签：图片标签">
      06-HTML标签：图片标签 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#本文主要内容"><span class="nav-number">1.</span> <span class="nav-text">本文主要内容</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#字体标签"><span class="nav-number">2.</span> <span class="nav-text">字体标签</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#特殊字符（转义字符）"><span class="nav-number">2.1.</span> <span class="nav-text">特殊字符（转义字符）</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#下划线、中划线、斜体"><span class="nav-number">2.2.</span> <span class="nav-text">下划线、中划线、斜体</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#粗体标签-lt-b-gt-或-lt-strong-gt-（已废弃）"><span class="nav-number">2.3.</span> <span class="nav-text">粗体标签&lt;b&gt;或&lt;strong&gt;（已废弃）</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#字体标签-lt-font-gt-（已废弃）"><span class="nav-number">2.4.</span> <span class="nav-text">字体标签&lt;font&gt;（已废弃）</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#上标-lt-sup-gt-下标-lt-sub-gt"><span class="nav-number">2.5.</span> <span class="nav-text">上标&lt;sup&gt;   下标&lt;sub&gt;</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#三、超链接"><span class="nav-number">3.</span> <span class="nav-text">三、超链接</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1、外部链接：链接到外部文件"><span class="nav-number">3.1.</span> <span class="nav-text">1、外部链接：链接到外部文件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2、锚链接"><span class="nav-number">3.2.</span> <span class="nav-text">2、锚链接</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3、邮件链接"><span class="nav-number">3.3.</span> <span class="nav-text">3、邮件链接</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#超链接的属性"><span class="nav-number">3.4.</span> <span class="nav-text">超链接的属性</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#备注1：分清楚img和a标签的各自的属性"><span class="nav-number">3.4.1.</span> <span class="nav-text">备注1：分清楚img和a标签的各自的属性</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#备注2：a是一个文本级的标签"><span class="nav-number">3.4.2.</span> <span class="nav-text">备注2：a是一个文本级的标签</span></a></li></ol></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="Gip886"
      src="/images/%E5%A4%B4%E5%83%8F.jpg">
  <p class="site-author-name" itemprop="name">Gip886</p>
  <div class="site-description" itemprop="description">为了更美好的明天而战</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">29</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">7</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/Gip886" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;Gip886" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
  </div>



      </div>
        <iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=300 height=86 src="//music.163.com/outchain/player?type=2&id=492390949&auto=1&height=66"></iframe>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Gip886</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-area"></i>
    </span>
      <span class="post-meta-item-text">站点总字数：</span>
    <span title="站点总字数">153k</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span class="post-meta-item-text">站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">2:19</span>
</div>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script size="300" alpha="0.6" zIndex="-1" src="/lib/canvas-ribbon/canvas-ribbon.js"></script>
  <script src="/lib/anime.min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js"></script>
  <script src="//cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>


  <script defer src="/lib/three/three.min.js"></script>
    <script defer src="/lib/three/canvas_lines.min.js"></script>


  




  
<script src="/js/local-search.js"></script>













  

  

<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","model":{"jsonPath":"/live2dw/assets/koharu.model.json"},"display":{"position":"right","width":150,"height":300},"mobile":{"show":true},"log":false,"tagMode":false});</script></body>
<!-- 页面点击小红心 -->
<script type="text/javascript" src="/js/clicklove.js"></script>
</html>

